package pack.bean;
import javax.faces.bean.ManagedBean;
import javax.persistence.EntityManager;

import pack.metier.Centre;
import pack.metier.Donneur;
import pack.persistence.Connexion;

@ManagedBean
public class AfficheDonneur {	
	protected String displayDonneur;
	
	protected String numeroHematie;
	protected String numeroDonneur;
	protected String nomDonneur; 
	protected String prenom;
	protected String dateNais;
	protected int civilite;
	protected String adresseLigne1;
	protected String adresseLigne2;
	protected String codePostal;
	protected String ville;
	protected String numDomicile;
	protected String numTravail;
	protected String numPortable;
	protected String email;
	protected long centrePrefere;
	protected int groupe=1;	 
	protected boolean d_up;
	protected boolean c_up;
	protected boolean c_down;
	protected boolean e_up;
	protected boolean e_down;
	protected boolean cw;
	protected boolean k_up;
	protected boolean k_down;
	protected boolean kpa;
	protected boolean kpb;
	protected boolean fya;
	protected boolean fyb;
	protected boolean jka;
	protected boolean jkb;
	protected boolean lea;
	protected boolean leb;
	protected boolean m_up;
	protected boolean n_up;
	protected boolean s_up;
	protected boolean s_down;
	protected boolean p1;
	protected boolean lua;
	protected boolean lub;
	protected String freqDons;

	public AfficheDonneur() {
		super();
	}	
	
	public void chargeDonneur(){		
		Connexion connexion = new Connexion();
		EntityManager em = connexion.getEm();
		Donneur donneur = em.find(Donneur.class, displayDonneur);
		if (donneur==null) return;
		numeroHematie=donneur.getNumeroHematie();
		numeroDonneur=donneur.getNumeroDonneur();
		nomDonneur=donneur.getNomDonneur(); 
		prenom=donneur.getPrenom();
		dateNais=donneur.getDateNais();
		civilite=donneur.getCivilite();
		adresseLigne1=donneur.getAdresseLigne1();
		adresseLigne2=donneur.getAdresseLigne2();
		codePostal=donneur.getCodePostal();
		ville=donneur.getVille();
		numDomicile=donneur.getNumDomicile();
		numTravail=donneur.getNumTravail();
		numPortable=donneur.getNumPortable();
		email=donneur.getEmail();
		centrePrefere=donneur.getCentrePrefere().getIdCentre();
		groupe=donneur.getGroupe();	 
		d_up=donneur.isD_up();
		c_up=donneur.isC_up();
		c_down=donneur.isC_down();
		e_up=donneur.isE_up();
		e_down=donneur.isE_down();
		cw=donneur.isCw();
		k_up=donneur.isK_up();
		k_down=donneur.isK_down();
		kpa=donneur.isKpa();
		kpb=donneur.isKpb();
		fya=donneur.isFya();
		fyb=donneur.isFyb();
		jka=donneur.isJka();
		jkb=donneur.isJkb();
		lea=donneur.isLea();
		leb=donneur.isLeb();
		m_up=donneur.isM_up();
		n_up=donneur.isN_up();
		s_up=donneur.isS_up();
		s_down=donneur.isS_down();
		p1=donneur.isP1();
		lua=donneur.isLua();
		lub=donneur.isLub();
		freqDons=donneur.getFreqDons();
	}

	public String getDisplayDonneur() {
		return displayDonneur;
	}

	public void setDisplayDonneur(String displayDonneur) {
		this.displayDonneur = displayDonneur;
	}

	public String getNumeroHematie() {
		return numeroHematie;
	}

	public void setNumeroHematie(String numeroHematie) {
		this.numeroHematie = numeroHematie;
	}

	public String getNumeroDonneur() {
		return numeroDonneur;
	}

	public void setNumeroDonneur(String numeroDonneur) {
		this.numeroDonneur = numeroDonneur;
	}

	public String getNomDonneur() {
		return nomDonneur;
	}

	public void setNomDonneur(String nomDonneur) {
		this.nomDonneur = nomDonneur;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public String getDateNais() {
		return dateNais;
	}

	public void setDateNais(String dateNais) {
		this.dateNais = dateNais;
	}

	public int getCivilite() {
		return civilite;
	}

	public void setCivilite(int civilite) {
		this.civilite = civilite;
	}

	public String getAdresseLigne1() {
		return adresseLigne1;
	}

	public void setAdresseLigne1(String adresseLigne1) {
		this.adresseLigne1 = adresseLigne1;
	}

	public String getAdresseLigne2() {
		return adresseLigne2;
	}

	public void setAdresseLigne2(String adresseLigne2) {
		this.adresseLigne2 = adresseLigne2;
	}

	public String getCodePostal() {
		return codePostal;
	}

	public void setCodePostal(String codePostal) {
		this.codePostal = codePostal;
	}

	public String getVille() {
		return ville;
	}

	public void setVille(String ville) {
		this.ville = ville;
	}

	public String getNumDomicile() {
		return numDomicile;
	}

	public void setNumDomicile(String numDomicile) {
		this.numDomicile = numDomicile;
	}

	public String getNumTravail() {
		return numTravail;
	}

	public void setNumTravail(String numTravail) {
		this.numTravail = numTravail;
	}

	public String getNumPortable() {
		return numPortable;
	}

	public void setNumPortable(String numPortable) {
		this.numPortable = numPortable;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public long getCentrePrefere() {
		return centrePrefere;
	}

	public void setCentrePrefere(long centrePrefere) {
		this.centrePrefere = centrePrefere;
	}

	public int getGroupe() {
		return groupe;
	}

	public void setGroupe(int groupe) {
		this.groupe = groupe;
	}

	public boolean isD_up() {
		return d_up;
	}

	public void setD_up(boolean d_up) {
		this.d_up = d_up;
	}

	public boolean isC_up() {
		return c_up;
	}

	public void setC_up(boolean c_up) {
		this.c_up = c_up;
	}

	public boolean isC_down() {
		return c_down;
	}

	public void setC_down(boolean c_down) {
		this.c_down = c_down;
	}

	public boolean isE_up() {
		return e_up;
	}

	public void setE_up(boolean e_up) {
		this.e_up = e_up;
	}

	public boolean isE_down() {
		return e_down;
	}

	public void setE_down(boolean e_down) {
		this.e_down = e_down;
	}

	public boolean isCw() {
		return cw;
	}

	public void setCw(boolean cw) {
		this.cw = cw;
	}

	public boolean isK_up() {
		return k_up;
	}

	public void setK_up(boolean k_up) {
		this.k_up = k_up;
	}

	public boolean isK_down() {
		return k_down;
	}

	public void setK_down(boolean k_down) {
		this.k_down = k_down;
	}

	public boolean isKpa() {
		return kpa;
	}

	public void setKpa(boolean kpa) {
		this.kpa = kpa;
	}

	public boolean isKpb() {
		return kpb;
	}

	public void setKpb(boolean kpb) {
		this.kpb = kpb;
	}

	public boolean isFya() {
		return fya;
	}

	public void setFya(boolean fya) {
		this.fya = fya;
	}

	public boolean isFyb() {
		return fyb;
	}

	public void setFyb(boolean fyb) {
		this.fyb = fyb;
	}

	public boolean isJka() {
		return jka;
	}

	public void setJka(boolean jka) {
		this.jka = jka;
	}

	public boolean isJkb() {
		return jkb;
	}

	public void setJkb(boolean jkb) {
		this.jkb = jkb;
	}

	public boolean isLea() {
		return lea;
	}

	public void setLea(boolean lea) {
		this.lea = lea;
	}

	public boolean isLeb() {
		return leb;
	}

	public void setLeb(boolean leb) {
		this.leb = leb;
	}

	public boolean isM_up() {
		return m_up;
	}

	public void setM_up(boolean m_up) {
		this.m_up = m_up;
	}

	public boolean isN_up() {
		return n_up;
	}

	public void setN_up(boolean n_up) {
		this.n_up = n_up;
	}

	public boolean isS_up() {
		return s_up;
	}

	public void setS_up(boolean s_up) {
		this.s_up = s_up;
	}

	public boolean isS_down() {
		return s_down;
	}

	public void setS_down(boolean s_down) {
		this.s_down = s_down;
	}

	public boolean isP1() {
		return p1;
	}

	public void setP1(boolean p1) {
		this.p1 = p1;
	}

	public boolean isLua() {
		return lua;
	}

	public void setLua(boolean lua) {
		this.lua = lua;
	}

	public boolean isLub() {
		return lub;
	}

	public void setLub(boolean lub) {
		this.lub = lub;
	}

	public String getFreqDons() {
		return freqDons;
	}

	public void setFreqDons(String freqDons) {
		this.freqDons = freqDons;
	}
	
	public String monCentre(){		
		Connexion connexion = new Connexion();
		EntityManager em = connexion.getEm();
		Centre centre = em.find(Centre.class, centrePrefere);
		if (centre==null) return "";
		return centre.getNomCentre()+" ("+centre.getVille()+")";
	}
	
}
